Working with Log Files

Using NLog, VBVLog, or VBVRLog, VBVoice can log all activity appearing in a log window to a file. INI file settings can also be used to control the amount of data recorded.

Enabling Logs

The INI file setting should contain the setting [System] Logs=1 to enable logs. Logs are organized into categories and each category can be turned on and off for each channel. Each log file contains the logs for all channels.

Filing in the Log Directory

Log files are stored in the directory set by the VBVFrame main property page. Filenames are derived from the date, for example:

Logger

Date

Filename

VBVLog

January 23rd

vbv23-01.vlg

NLog

January 23rd

Jan23_1.vln

In VBVLog, if more than one application is running, a suffix is added to the file to avoid conflict; for example, vbv23-01aa.vlg.

The log file is closed every day at midnight and a new file is created. If a relative path name is specified for this directory, the directory relative to the VBVoiceproject directory is used. For example, if the project directory is c:\myapp, the log files are created in c:\myapp\logs.

Displaying Log Files

Load log files into a log window at runtime using the File | Load Previous Logs menu command. Only logs for the selected channel are displayed.

With NLog, if you select Generate a .log text file in the Select Logs to Show dialog, a .log file for the selected .vlg file is created. The log files may be large but they can be viewed in an ordinary text editor.

Deciphering Error Codes

-1

no filename

1 to 10

error code returned by file system

100, 101, 102

incorrect log version

Adding Information to the Log

Use the Log object exposed by the VBVoice support dll (vbvcom.dll) to add your own logs to the VBVoice log file and to the log windows.

To add a log entry, use this code:

Dim mylog as new VBVLog
mylog.AddLogItem 1, 0, "this is a line of text for channel 1"

Parameter 1 is the channel number, parameter 2 should always be 0.

Sending Custom Errors to the Log

Use the function AddErrorItem, which is supported by vbvcom.dll and which is dedicated to error messages generated by VBVoice developers, to send custom errors to the Log.

Ten different predefined errors are available for classifying custom errors:

Error Name

Type

CustomError0

0

CustomError1

1

CustomError2

2

CustomError3

3

CustomError4

4

CustomError5

5

CustomError6

6

CustomError7

7

CustomError8

8

CustomError9

9

Assign each error to a class of errors that you want to observe in an application. For example, CustomError0 may be assigned to all errors incurred while connecting to a database, whereas CustomError1 may be assigned to failures in Internet connections.

Use this code to generate such errors from a VB application:

Dim mylog as new VBVLog
mylog.AddErrorItem 1, 0, "Error connecting to mylibrary database"

Where parameter 1 is the channel number, parameter 2 is the custom error type (any value from 0 to 9), and parameter 3 is an arbitrary string of text.

While errors generated by calling this function do not block a call or stop the system from running, they are treated like any other VBVoice error in VBVLog and NLog programs.

By adjusting settings in the VBVLog section of vbvoice.ini, you can set error severity so that they follow VBVoice Runtime error rules of showing the Windows System Logs (with subsequent translation into SNMP traps).

Read more about VBVoice errors in Appendix 3 and learn how to setup VBVoice to generate SNMP traps.

Deleting Old Log Files

Log files become large on busy systems and consume a large amount of disk space. Use the DeleteOldLogs INI setting to tell VBVoice to delete old logs of a certain age. These logs will be deleted automatically at midnight every day.